//
//  WYMyFollowController.m
//  Boss
//
//  Created by admin on 2018/7/2.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYMyFollowController.h"
#import "SGPagingView.h"
#import "WYMyFollowListController.h"
@interface WYMyFollowController ()<SGPageTitleViewDelegate,SGPageContentScrollViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentScrollView *pageContentView;
@property (nonatomic,strong) WYMyFollowListController *oneVc;
@property (nonatomic,strong) WYMyFollowListController *twoVc;
@end

@implementation WYMyFollowController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    
}






-(void)setupUI
{
    
    NSArray *titleArr = @[@"我的关注", @"我的粉丝"];
    
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.titleColor =[UIColor hexStringToColor:@"#f7ddd8" alpha:1.0];
    configure.titleSelectedColor = [UIColor hexStringToColor:@"#ffffff" alpha:1.0];
    configure.indicatorColor = [UIColor whiteColor];
    configure.indicatorHeight = 2.f;
    configure.indicatorStyle = SGIndicatorStyleDefault;
    configure.showBottomSeparator = NO;
    configure.indicatorAdditionalWidth = 4;
    configure.indicatorFixedWidth = 4.f;
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 0, self.view.frame.size.width-88, 43) delegate:self titleNames:titleArr configure:configure];
   // [self.view addSubview:_pageTitleView];
    self.pageTitleView.backgroundColor = kColorMainColor;
//    self.pageTitleView.titleColorStateNormal = [UIColor hexStringToColor:@"#f7ddd8" alpha:1.0];
//    self.pageTitleView.titleColorStateSelected = [UIColor hexStringToColor:@"#ffffff" alpha:1.0];
//    self.pageTitleView.indicatorColor = [UIColor whiteColor];
//    self.pageTitleView.indicatorHeight = 4.f;
//    self.pageTitleView.indicatorLengthStyle = SGIndicatorLengthTypeDefault;
//    self.pageTitleView.isShowBottomSeparator = NO;
    
    self.navigationItem.titleView = self.pageTitleView;
    
    WYMyFollowListController *oneVC = [[WYMyFollowListController alloc]init];
    oneVC.type = @"1";
    self.oneVc = oneVC;
    WYMyFollowListController *twoVC = [[WYMyFollowListController alloc]init];
    twoVC.type = @"2";
    self.twoVc = twoVC;
    NSArray *childVCArr = @[oneVC, twoVC];
    CGFloat contentViewHeight = kScreenHeight - self.navHeight;
    self.pageContentView = [[SGPageContentScrollView alloc] initWithFrame:CGRectMake(0, self.navHeight, self.view.frame.size.width, contentViewHeight) parentVC:self childVCs:childVCArr];
    _pageContentView.delegatePageContentScrollView = self;
    [self.view addSubview:_pageContentView];
    
}
- (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
{
    NSLog(@"-------%ld",targetIndex);
    [self.twoVc refreshloadData];
    [self.oneVc refreshloadData];
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
{
    [self.twoVc refreshloadData];
    [self.oneVc refreshloadData];
    NSLog(@"------------------%ld",selectedIndex);
    [self.pageContentView setPageContentScrollViewCurrentIndex:selectedIndex];
}


@end
